package com.dudsbury.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;


import javax.swing.Action;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.text.DefaultEditorKit;


import com.dudsbury.jtablestuff.CustomTable;


public class CustomFileMenu extends JMenuBar implements ActionListener {
	
	JMenu fileMenu,editMenu,viewMenu,helpMenu,customerMenu,itemMenu,searchMenu;
	JMenuItem createUserItem, exitItem, loginItem, cutItem, copyItem, pasteItem, weekItem, monthItem, dateItem, createCustomerItem, createItemItem, searchItem, aboutTutorialItem, aboutSystemItem;
	protected CustomTable table;
	
	public CustomFileMenu() {
		
		table = MainFrame.table;
		fileMenu = new JMenu("File");
		editMenu = new JMenu("Edit");
		customerMenu = new JMenu("Customer");
		itemMenu = new JMenu("Item");
		searchMenu = new JMenu("Search");
		helpMenu = new JMenu("Help");
		 
		
		
		add(fileMenu);
		add(editMenu);
		add(customerMenu);
		add(itemMenu);
		add(searchMenu);
		add(helpMenu);
		
		
		//FILE
		JMenuItem createUserItem = new JMenuItem("Create User");
		createUserItem.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new CreateUserScreen();
			}
		});
		fileMenu.add(createUserItem);
		
		fileMenu.addSeparator();
		
		
		JMenuItem exitItem = new JMenuItem("Exit");
		exitItem.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
			System.exit(0);	
			}			
		});
		fileMenu.add(exitItem);
		
		//EDIT
		JMenuItem cutItem = new JMenuItem(new DefaultEditorKit.CutAction());
		cutItem.setText("Cut");
		editMenu.add(cutItem);
	    
		JMenuItem copyItem = new JMenuItem(new DefaultEditorKit.CopyAction());
		copyItem.setText("Copy");
		editMenu.add(copyItem);
		
		JMenuItem pasteItem = new JMenuItem(new DefaultEditorKit.PasteAction());
		pasteItem.setText("Paste");
		editMenu.add(pasteItem);
		
		//CUSTOMER
		JMenuItem createCustomerItem = new JMenuItem("New Customer");
		createCustomerItem.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new CustomerScreen().setVisible(true);
				System.out.println("screen running");
			}
		});
		customerMenu.add(createCustomerItem);
		
		//ITEM
		JMenuItem createItemItem = new JMenuItem("Create Item");
		createItemItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new CreateItemScreen();		
			}
			});
		itemMenu.add(createItemItem);
		
		//SEARCH
		//Not Coded yet
		JMenuItem searchItem = new JMenuItem("Search");
		searchItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new SearchScreen();		
			}
			});
		searchMenu.add(searchItem);

		
		//HELP
		//Not Coded yet
		JMenuItem aboutTutorialItem = new JMenuItem("View Tutorial");
		aboutTutorialItem.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				try {
					new TutorialFrame();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		helpMenu.add(aboutTutorialItem);	
		
		helpMenu.addSeparator();
		
		JMenuItem aboutSystemItem = new JMenuItem("About Dudsbury Booking System");
		aboutSystemItem.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new About();
			}
		});
		helpMenu.add(aboutSystemItem);
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	}


